/**
 *******************************************************************************
 * @file rtc_driver.h
 * @author .ISS_AUTO (hudandan@issauto.com)
 * @version xx.xx.xx
 * @date    xx.xx.xx
 * @brief
 *
 * @copyright Copyright (c) 2024 ISSAUTO TECH Co., Ltd. All rights reserved.
 *
 *******************************************************************************
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef _RTC_DRIVER_H
#define _RTC_DRIVER_H

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Exported types ------------------------------------------------------------*/
typedef struct __RTC_DriverTypeDef {
    RTC_InitType RTC_InitParam;     /*!< RTC parameters */
    RTC_TimeType  *p_TimeParam;
    RTC_DateType  *p_DateParam;
    RTC_AlarmType *p_A_AlarmParam;
    RTC_AlarmType *p_B_AlarmParam;

    void (*IrqHandlerISR)(void *drtc); /*!< RTC function pointer on IrqHandler   */

} RTC_DriverTypeDef; /* 参考自stm32_hal库 */


/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
// #define log_info(M, ...)    USER_PRINTF(M, ##__VA_ARGS__)
#define log_info(M, ...)

/**
 * @param CLK_SRC_TYPE specifies RTC Source Clock Type.
 *   This parameter can be on of the following values:
 *       @arg RTC_CLK_SRC_TYPE_HSE128:    RTC clock source is HSE/128
 *       @arg RTC_CLK_SRC_TYPE_LSE:       RTC clock source is LSE,and LSE is oscillator
 *       @arg RTC_CLK_SRC_TYPE_LSI:       RTC clock source is LSI
 */
#define RTC_CLK_SRC_TYPE_HSE128    (0U)
#define RTC_CLK_SRC_TYPE_LSE       (1U)
#define RTC_CLK_SRC_TYPE_LSI       (2U)

#define CLK_SRC_TYPE               (2U) //!< RTC_CLK_SRC_TYPE_LSI

/* Exported variables --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
ErrorStatus RTC_AlarmRegulate(uint32_t RTC_Alarm, RTC_AlarmType *pAlarm);
ErrorStatus RTC_DateRegulate(RTC_DateType *pDate);
ErrorStatus RTC_TimeRegulate(RTC_TimeType *pTime);

void RTC_AlarmShow(uint8_t AlarmX, RTC_AlarmType *pRTC_Alarm);
void RTC_DateShow(RTC_DateType *pRTC_Data);
void RTC_TimeShow(RTC_TimeType *pRTC_Time);
void RTC_TimeStampShow(void);
ErrorStatus RTC_Configuration(RTC_DriverTypeDef *prtc);
void EXTI17_RTCAlarm_Configuration(FunctionalState Cmd);
void EXTI20_RTCWKUP_Configuration(FunctionalState Cmd);

#endif/* _RTC_DRIVER_H */

/* END OF FILE ---------------------------------------------------------------*/
